package s03;

/**
 * @ClassName ThreadDemo03
 * @Description TODO
 * @Author Li
 * @Date 2022/8/8 9:55
 * @ModifyDate 2022/8/8 9:55
 * @Version 1.0
 */
public class ThreadDemo03 {
    public static void main(String[] args) {
        // 下面这个整体，相当于new MyRunnable()
        /*new Runnable(){
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println("运行线程 -> " + i);
                }
            }
        };*/
        Runnable r = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 20; i++) {
                    System.out.println("匿名线程 -> " + i);
                }
            }
        };
        new Thread(r).start(); // 启动线程
        for (int i = 0; i < 20; i++) {
            System.out.println("main线程 -> " + i);
        }
    }
}
